package com.inossem.warehousestorage_inossem.request.outStorage;

import android.content.Context;

import com.google.gson.Gson;
import com.inossem.warehousestorage_inossem.bean.outStorage.OutStoragePickingBatchListBean;
import com.inossem.warehousestorage_inossem.constant.RequestConstant;
import com.inossem.warehousestorage_inossem.listener.GsonBeanListener;
import com.inossem.warehousestorage_inossem.listener.StringRequestListener;
import com.inossem.warehousestorage_inossem.manage.RequestManage;
import com.inossem.warehousestorage_inossem.model.StringResponse;
import com.inossem.warehousestorage_inossem.request.Request;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by leij on 2017/6/12.
 */

public class OutStorageReturnDefaultBatchRequest extends Request {

    private static final String MATERIEL_CODE = "materielCode";//物料编码

    private static final String NUMBER = "number";//数量

    private static final String WERKS = "werks";//工厂

    private static final String INVENTORYA_DDRESS_CODE = "inventoryAddressCode";//库存地点

    private static final String SUPPLIER = "supplier"; //供应商

    public static String request(Context context, String materielCode, String number, String werks, String inventoryAddressCode, String supplier, GsonBeanListener gsonBeanListener) {
        String tag;
        Map<String, String> params = new HashMap<>();
        params.put(MATERIEL_CODE, materielCode);
        params.put(NUMBER, number);
        params.put(WERKS, werks);
        params.put(INVENTORYA_DDRESS_CODE, inventoryAddressCode);
        params.put(SUPPLIER, supplier);
        String url = RequestManage.getUrl(context,RequestConstant.URL_OUT_STORAGE_RETURN_DEFAULT_BATCH + RequestManage.mapEncodeToParams(params));
        tag = RequestManage.getHttpsGetWithLoading(context, url, new StringRequestListener() {
            @Override
            public void onSuccess(StringResponse stringRequestResponse) {
                Gson gson = new Gson();
                OutStoragePickingBatchListBean bean = gson.fromJson(stringRequestResponse.getResponseInfo(), OutStoragePickingBatchListBean.class);
                excuteJsonBean(context, bean, bean.getCode(), bean.getMsg(), gsonBeanListener);
            }
        });
        return tag;
    }

}
